function showAllPositionsByDate(){
	
	if(ckb_all_selected.checked){
		
		var elementos = document.getElementsByName("ckb_ponto");
		for(var i=0;i< elementos.length;i++){
			if(elementos[i].checked){
				//alert("rem " + elementos[i].id );
				removeMarkers(elementos[i]);
			}
			
			elementos[i].checked = true;
		}  
		GetAllData();
		return true;
		
	}else{
		
		removeAllMarkers();
		
		var elementos = document.getElementsByName("ckb_ponto");
		for(var i=0;i< elementos.length;i++){
			elementos[i].checked = false;
		} 
		return true;
	}	
}

function GetAllData(){
	
	hr.open("POST", "../controller/GetAllData.php", true);

	hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

	hr.onreadystatechange = function() {

		if(hr.readyState == 4 && hr.status == 200) {

			var data = JSON.parse(hr.responseText);

			for(var obj in data.ponto){
				
				var ponto = new Object();
				//alert(data.ponto[obj].id);
				
				ponto.active = true;
				ponto.id   = data.ponto[obj].id;
				ponto.nome = data.ponto[obj].nome;
				ponto.info = data.ponto[obj].info;
				ponto.icon = data.ponto[obj].icon;
				
				var arrayPosicoes = new Array();

				for(var pos in data.ponto[obj].posicoes){
					
					var posicao = new Object();
					
					posicao.idPackage  = data.ponto[obj].posicoes[pos].idPackage;
					posicao.typeData   = data.ponto[obj].posicoes[pos].typeData;
					posicao.latitude   = data.ponto[obj].posicoes[pos].latitude;
					posicao.longitude  = data.ponto[obj].posicoes[pos].longitude;
					posicao.velocidade = data.ponto[obj].posicoes[pos].velocidade;
					posicao.dateTime   = data.ponto[obj].posicoes[pos].dateTime;
					posicao.latlng	   = new google.maps.LatLng(data.ponto[obj].posicoes[pos].latitude,data.ponto[obj].posicoes[pos].longitude);
					
					arrayPosicoes.push(posicao);
				}
				
				ponto.arrayPosicoes = arrayPosicoes;		
				
				arrayPontos[ponto.id] = ponto;
				
			}
			addAllMarkers();
			
		};
	}
	
	hr.send("idUsuario="+idUsuario);
}

//Function for adding a marker to the page.
function addAllMarkers(){
	
	
	for(var obj in arrayPontos){
				
		var tmp_id = arrayPontos[obj].id;
		var arrayMarkers = new Array();
		
		for(var pos in arrayPontos[tmp_id].arrayPosicoes){
			
			var mark =  new Object();
			//alert(arrayPontos[tmp_id].arrayPosicoes[pos].idPackage);
			mark.idPackage = arrayPontos[tmp_id].arrayPosicoes[pos].idPackage;
			
			var icon;
		
			mark.marker = new google.maps.Marker({ position:arrayPontos[tmp_id].arrayPosicoes[pos].latlng,
												map: map,
												draggable:true,
												title:"idPackage:"+mark.idPackage
												//icon: "http://maps.google.com/mapfiles/ms/micons/blue.png"
			});
							
			mark.infowindow = new google.maps.InfoWindow({
				//<br/>Latitude: '+objPosicao.latitude+'<br/>Longitude:'+data[obj].longitude+'
				content: '<font color="#000000" size=1>Nome:'+arrayPontos[tmp_id].nome+'<br/>idPackage:'+arrayPontos[tmp_id].arrayPosicoes[pos].idPackage+'<br/>Date Time:'+arrayPontos[tmp_id].arrayPosicoes[pos].dateTime+'<br/>Velocidade:'+arrayPontos[tmp_id].arrayPosicoes[pos].velocidade+'<font />'
			});
		
			map.setCenter(arrayPontos[tmp_id].arrayPosicoes[0].latlng);
			map.setZoom(16);
			
			addAllListener(mark.marker, mark.infowindow);
			
			arrayMarkers.push(mark);
			
		}
		
		arrayPontos[tmp_id].arrayMarkers = arrayMarkers;
	}
	
}

function addAllListener(p_marker,p_infowindow){

	google.maps.event.addListener(p_marker, 'click', function() {
		p_infowindow.open(map,p_marker);
	});
}